function ShowHideDiv(divname,divnumber, numberdiv, prefix)
{
	for(i=1;i<=numberdiv;i++)
	{
		o = document.getElementById(divname+i);
		a = document.getElementById(prefix+divname+i);
		a.className = '';
		o.style.display = 'none';
	}
	o = document.getElementById(divname+divnumber);
	a = document.getElementById(prefix+divname+divnumber);
	a.className = 'selected';
	o.style.display = 'block';
}
function chkcolor(rowid,normal,td)
{
		alert(rowid);
		var box = document.getElementById(td);
		var row = document.getElementById(rowid);
		if(row.className == normal && box.checked == true)
		{	
			
			row.className = "chkselected";			
		}
		else
		{
			row.className = normal;
		}
		
}
function changecolor(total)
{
		for(i=0;i<=total;i++)
		{
				
		}
}
function editOptionValue(id){
	//get object
	var obj = document.getElementById(id);
	var btnEdit = document.getElementById("edit"+id);
	var btnDelete = document.getElementById("delete"+id);
	var btnSave = document.getElementById("save"+id);
	var txtVietnam = document.getElementById("vietnam"+id);
	var txtEnglish = document.getElementById("english"+id);
	var txtValue = document.getElementById("value"+id);
	
	//hide show button
	btnEdit.style.display = 'none';
	btnDelete.style.display = 'none';
	btnSave.style.display = '';
	
	//change css
	obj.className = "save";
	//enable textbox

}

function deleteOptionValue(id){
	//get object
	var obj = document.getElementById(id);
	//
	if(confirm("Are you sure you want to delete this item?") == true) obj.style.display = 'none';
	obj.innerHTML=""
}

function saveOptionValue(id){
	//get object
	var obj = document.getElementById(id);
	var btnEdit = document.getElementById("edit"+id);
	var btnDelete = document.getElementById("delete"+id);
	var btnSave = document.getElementById("save"+id);
	var txtVietnam = document.getElementById("vietnam"+id);
	var txtEnglish = document.getElementById("english"+id);
	var txtValue = document.getElementById("value"+id);

	//hide show button
	btnEdit.style.display = '';
	btnDelete.style.display = '';
	btnSave.style.display = 'none';

	//change css
	obj.className = "edit";
}

function addOptionValue(){
	//get object
	
	var table = document.getElementById("tblOptionValue");
	var frm = document.getElementById("formAddRow");
	//validate
	//if(frm.subimage.value == ""){alert("Please enter chose Image"); return false;};
	
	addRowToTable();
}

function addRowToTable()
{
  var tbl = document.getElementById('tblOptionValue');
  var frm = document.getElementById("formAddRow");
  
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow+1;
  var row = tbl.insertRow(lastRow);
  row.id = "Row"+iteration;
  row.className = "edit";
  
  // Vietnam Cell
  var cell1 = row.insertCell(0);
  var el = document.createElement('input');
  el.type = 'file';
  el.id = 'subimageRow' + iteration;
  el.name = 'subimageRow' + iteration;
  //el.value = frm.subimage.value;
  //el.className = "textbox";
  //el.disabled = true;
  cell1.appendChild(el);
  
  //el.disabled = true;
  var cell4 = row.insertCell(1);
  
  var strHTML = "";
  //strHTML += "<a id=saveRow"+iteration+" onclick=saveOptionValue('Row"+iteration+"') style='display:none'>[Save]</a>";
  //strHTML += "<a id=editRow"+iteration+" onclick=editOptionValue('Row"+iteration+"')>[Edit]</a>&nbsp";
  strHTML += "<a id=deleteRow"+iteration+" onclick=deleteOptionValue('Row"+iteration+"')>[Delete]</a><input type='hidden' name=Rows["+iteration+"]>";
  cell4.innerHTML = strHTML;
  //var textNode = document.createTextNode("[Save]");
  //cell4.appendChild(textNode);
  
}

function addOptionRow(text1, text2, optid)
{
	var elem=document.getElementById(setListName);
	var i=$(setSelector+' li').size() + 1;
	var oLi=document.createElement("li");
	oLi.id = "Row"+i;
	elem.appendChild(oLi);
	var strHTML = "";
	strHTML += "<table class=tbatt style='width:95%' border=1 cellpadding=0 cellspacing=0>";
    strHTML += "<tr class=add>";
    strHTML += "<td id=col1Row"+i+" width=30%>"+text1+"</td>";
    strHTML += "<td id=col2Row"+i+" width=30%>"+text2+"</td>";
    strHTML += "<td width=60%>";
    strHTML += "<textarea class=textarea id=valueRow"+i+" type=text name=valueRow["+i+"] value='' ></textarea>";
	strHTML += "<input id=idRow"+i+" type=hidden name=idRow["+i+"] value="+optid+" />";
	strHTML += "<input id=positionRow"+i+" type=hidden name=positionRow["+i+"] value='"+i+"' />";
    strHTML += "</td>"
    strHTML += "</tr>";
    strHTML += "</table>";
	oLi.innerHTML = strHTML;	
}
function addOptionSize()
{
 //get object

 var table = document.getElementById("tblOptionValue");
 var frm = document.getElementById("formAddRow");
 //validate
 //if(frm.subimage.value == ""){alert("Please enter chose Image"); return false;};

 addRowSizeToTable();
}

function addRowSizeToTable()
{
  var tbl = document.getElementById('tblOptionValue');
  var frm = document.getElementById("formAddRow");
  
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow+1;
  var row = tbl.insertRow(lastRow);
  row.id = "Row"+iteration;
  row.className = "edit";
  
  // Vietnam Cell
  var cell1 = row.insertCell(0);
  var el = document.createElement('input');
  el.type = 'text';
  el.id = 'textRow' + iteration;
  el.name = 'size' + iteration;
  //el.value = frm.subimage.value;
  //el.className = "textbox";
  //el.disabled = true;
  cell1.appendChild(el);
  
  var cell1 = row.insertCell(1);
  var e2 = document.createElement('input');
  e2.type = 'file';
  e2.id = 'imageRow' + iteration;
  e2.name = 'imageRow' + iteration;
  //el.value = frm.subimage.value;
  //el.className = "textbox";
  //el.disabled = true;
  cell1.appendChild(e2);
  //el.disabled = true;
  var cell4 = row.insertCell(2);
  
  var strHTML = "";
  //strHTML += "<a id=saveRow"+iteration+" onclick=saveOptionValue('Row"+iteration+"') style='display:none'>[Save]</a>";
  //strHTML += "<a id=editRow"+iteration+" onclick=editOptionValue('Row"+iteration+"')>[Edit]</a>&nbsp";
  strHTML += "<a id=deleteRow"+iteration+" onclick=deleteOptionValue('Row"+iteration+"')>[Delete]</a><input type='hidden' name=Rows["+iteration+"]>";
  cell4.innerHTML = strHTML;
  //var textNode = document.createTextNode("[Save]");
  //cell4.appendChild(textNode);
  
}


function findSearch(divname,value)
{
	var obj = document.getElementById(divname)
	
	obj.innerHTML=value
}